﻿using EPiServer;
using EPiServer.DynamicContent;

namespace SocialPack.modules.SocialPack.DynamicContent.Linkedin
{
    [DynamicContentPlugIn(
        DisplayName = "Apply with Linkedin",
        Description = "Displays Apply with Linkedin",
        ViewUrl = "~/modules/socialpack/dynamiccontent/linkedin/ApplyWithLinkedin.ascx")]
    public partial class ApplyWithLinkedin : UserControlBase
    {
        public string APIKey { get; set; }

        public string ThemeColor { get; set; }

        public string JobLocation { get; set; }

        public string JobTitle { get; set; }

        public string RecipientEmail { get; set; }

        public string CompanyId { get; set; }

        public string CompanyLogo { get; set; }

        public bool IsPhoneRequired { get; set; }

        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!string.IsNullOrWhiteSpace(this.APIKey))
            {
                this.ApplyWithLinkedinControl.APIKey = this.APIKey;
            }

            if (!string.IsNullOrWhiteSpace(this.ThemeColor))
            {
                this.ApplyWithLinkedinControl.ThemeColor = this.ThemeColor;
            }

            if (!string.IsNullOrWhiteSpace(this.JobLocation))
            {
                this.ApplyWithLinkedinControl.JobLocation = this.JobLocation;
            }

            if (!string.IsNullOrWhiteSpace(this.JobTitle))
            {
                this.ApplyWithLinkedinControl.JobTitle = this.JobTitle;
            }

            if (!string.IsNullOrWhiteSpace(this.RecipientEmail))
            {
                this.ApplyWithLinkedinControl.RecipientEmail = this.RecipientEmail;
            }

            if (!string.IsNullOrWhiteSpace(this.CompanyId))
            {
                this.ApplyWithLinkedinControl.CompanyId = this.CompanyId;
            }

            if (!string.IsNullOrWhiteSpace(this.CompanyLogo))
            {
                this.ApplyWithLinkedinControl.CompanyLogo = this.CompanyLogo;
            }

            this.ApplyWithLinkedinControl.IsPhoneRequired = this.IsPhoneRequired;
        }
    }
}